(function () {
    var APP = function () {};

    APP.prototype = {
        run: function () {
            //code
        },

        build: function () {
            var htmlOutput = [
                '<div id="LoLTHTitle" align="center">Tribunal Helper - Case: ' + LoLTH.Summary['Case Number'] + '</div>',
                '<div id="LoLTHAccord">',
                '<p class="LoLTHHeader">Summary</p>',
                '<div id="LoLTHSummary" class="LoLTHBlock">',
                'Verdict: ' + LoLTH.Summary['Verdict'] + '</br>Tribunal Helper Score: ' + LoLTH.Summary['Score'] + '</br>',
                'Total Reports: '+LoLTH.Summary['Total Reports']+'</br> Total Games: '+LoLTH.Summary['Total Games'],
                '</div>'
            ];

            return htmlOutput.join('');
        },

        parse: function (game) {
            var parser, gameData, reports, reportName, score, i, j;

            for (i = 1; i <= LoLTH.Summary["Total Games"]; i = i + 1) {
                gameData = $('#game'+i);

                LoLTH.Game[i]["Outcome"] = gameData.find('#stat-outcome-fill').text();
                LoLTH.Game[i]["Game Length"] = gameData.find('#stat-length-fill').text();
                LoLTH.Game[i]["Mode"] = gameData.find('#stat-type-fill').text();
                LoLTH.Game[i].TotalScore = 0;
                LoLTH.Game[i].reports = {};

                reports = gameData.find(".report-reason");

                for (j = 0; j < reports.length; j = j + 1) {
                    reportName = reports[j].innerHTML;

                    parser = LoLTH.scorer.I18n.getCode(reportName);
                    parser = new LoLTH.scorer[parser](gameData);

                    score = parser.getScore();

                    console.log(reportName+": "+score);
                    LoLTH.Game[i].reports[j] = [ reportName , score ];
                    LoLTH.Game[i].TotalScore += score;
                }
                LoLTH.Game[i].TotalReports = reports.length;

                LoLTH.Game[i]["Score"] = LoLTH.Utility.Round( (LoLTH.Game[i].TotalScore / ( LoLTH.Game[i].TotalReports - ( LoLTH.Game[i].TotalReports * .1) ) ), 1);
                if ( LoLTH.Game[i]["Score"] > 10 ) { LoLTH.Game[i]["Score"] = 10 }

                LoLTH.Summary["Score"] += LoLTH.Game[i]["Score"];
            }
        }
    };

    LoLTH.App = new APP();
}());